<?php

/*
=====================================================
 FluxBB - Delux Board Converstations (DBC)
-----------------------------------------------------
 http://dbc-forum.com/
 http://fluxbb.org/
-----------------------------------------------------
 Copyright (c) 2010,2011 FluxBB - Delux Board Conversations (DBC)
-----------------------------------------------------
 Предсловие: Данный скрипт (DBC) не является работой с нуля, то 
 есть ядром скрипта всё также остаётся FuxBB,но теперь в оболочке
 DBC.
=====================================================
*/

if (!defined('DBC_ROOT'))
	exit('The constant DBC_ROOT must be defined and point to a valid Delux Board Conversations installation root directory.');

// Define the version and database revision that this code was written for
define('FORUM_VERSION', '1.5');

define('FORUM_VER_REVISION', 1);	// номер сборки

define('DBC_DEBUG', 1);

define('FORUM_DB_REVISION', 8);
define('FORUM_SI_REVISION', 1);
define('FORUM_PARSER_REVISION', 1);

// Block prefetch requests
if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
{
	header('HTTP/1.1 403 Prefetching Forbidden');

	// Send no-cache headers
	header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :)
	header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
	header('Cache-Control: post-check=0, pre-check=0', false);
	header('Pragma: no-cache'); // For HTTP/1.0 compatibility

	exit;
}

// Attempt to load the configuration file config.php
if (file_exists(DBC_ROOT.'engine/data/config.php'))
	require DBC_ROOT.'engine/data/config.php';

// If we have the 1.3-legacy constant defined, define the proper 1.4 constant so we don't get an incorrect "need to install" message
if (defined('FORUM'))
	define('DBC', FORUM);

// If DBC isn't defined, config.php is missing or corrupt
if (!defined('DBC'))
	exit('<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="templates/Default/css/style.css" />
<title>Delux Board Conversations Installation</title>
<link rel="shortcut icon" href="favicon.ico" />
<DBC_head>
</head>

<body>

<div id="DBCredirect" class="DBC_2">
<div class="top-box"><div><!-- Top Corners --></div></div>
<div class="DBCwrap">

<div id="brdmain">
			<h1><span>Delux Board Conversations 1.5</span></h1>
			<div id="brddesc"><p>Файл <b>\'config.php\'</b> не существует или поврежден. Пожалуйста, запустите <a href="install.php"><b>install.php</b></a> для установки Delux Board Conversations.</p></div><br/>
			<div id="brddesc" style="font-style: italic;">В случае возникновения проблем просьба обратиться на <a href="http://dbc-forum.com/support/" target="_blank">форум поддержки DBC</a>.</div>
</div>

<DBC_footer>

</div>
<div class="end-box"><div><!-- Bottom Corners --></div></div>
</div>

</body>
</html>');

// Load the functions script
require DBC_ROOT.'engine/functions.php';

// Load UTF-8 functions
require DBC_ROOT.'engine/utf8/utf8.php';

// Strip out "bad" UTF-8 characters
forum_remove_bad_characters();

// Reverse the effect of register_globals
forum_unregister_globals();

// Record the start time (will be used to calculate the generation time for the page)
$DBC_start = get_microtime();

// Make sure PHP reports all errors except E_NOTICE. BDC supports E_ALL, but a lot of scripts it may interact with, do not
//error_reporting(E_ALL);
error_reporting(E_ALL ^ E_NOTICE);

// Force POSIX locale (to prevent functions such as strtolower() from messing up UTF-8 strings)
setlocale(LC_CTYPE, 'C');

// Turn off magic_quotes_runtime
if (get_magic_quotes_runtime())
	set_magic_quotes_runtime(0);

// Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
if (get_magic_quotes_gpc())
{
	function stripslashes_array($array)
	{
		return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
	}

	$_GET = stripslashes_array($_GET);
	$_POST = stripslashes_array($_POST);
	$_COOKIE = stripslashes_array($_COOKIE);
	$_REQUEST = stripslashes_array($_REQUEST);
}

// If a cookie name is not specified in config.php, we use the default (DBC_cookie)
if (empty($cookie_name))
	$cookie_name = 'DBC_cookie';

// If the cache directory is not specified, we use the default setting
if (!defined('FORUM_CACHE_DIR'))
	define('FORUM_CACHE_DIR', DBC_ROOT.'engine/cache/');

// Define a few commonly used constants
define('DBC_UNVERIFIED', 0);
define('DBC_ADMIN', 1);
define('DBC_MOD', 2);
define('DBC_GUEST', 3);
define('DBC_MEMBER', 4);

// Load DB abstraction layer and connect
require DBC_ROOT.'engine/data/dblayer/common_db.php';

// Start a transaction
$db->start_transaction();

// Load cached config
if (file_exists(FORUM_CACHE_DIR.'cache_config.php'))
	include FORUM_CACHE_DIR.'cache_config.php';

if (!defined('DBC_CONFIG_LOADED'))
{
	if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
		require DBC_ROOT.'engine/cache.php';

	generate_config_cache();
	require FORUM_CACHE_DIR.'cache_config.php';
}

// Verify that we are running the proper database schema revision
if (!isset($DBC_config['o_database_revision']) || $DBC_config['o_database_revision'] < FORUM_DB_REVISION ||
		!isset($DBC_config['o_searchindex_revision']) || $DBC_config['o_searchindex_revision'] < FORUM_SI_REVISION ||
		!isset($DBC_config['o_parser_revision']) || $DBC_config['o_parser_revision'] < FORUM_PARSER_REVISION ||
		!isset($DBC_config['o_cur_ver_revision']) || $DBC_config['o_cur_ver_revision'] < FORUM_VER_REVISION ||
		version_compare($DBC_config['o_cur_version'], FORUM_VERSION, '<'))
	exit('Your Delux Board Conversations database is out-of-date and must be upgraded in order to continue. Please run <a href="'.DBC_ROOT.'db_update.php">db_update.php</a> in order to complete the upgrade process.');

// Enable output buffering
if (!defined('DBC_DISABLE_BUFFERING'))
{
	// Should we use gzip output compression?
	if ($DBC_config['o_gzip'] && extension_loaded('zlib'))
		ob_start('ob_gzhandler');
	else
		ob_start();
}

// Define standard date/time formats
$forum_time_formats = array($DBC_config['o_time_format'], 'H:i:s', 'H:i', 'g:i:s a', 'g:i a');
$forum_date_formats = array($DBC_config['o_date_format'], 'd.Y.m', 'Y.d.m', 'd.m.Y', 'm.d.Y', 'M j Y', 'jS M Y');

// Check/update/set cookie and fetch user info
$DBC_user = array();
check_cookie($DBC_user);

// Attempt to load the common language file
if (file_exists(DBC_ROOT.'language/'.$DBC_user['language'].'/common.php'))
	include DBC_ROOT.'language/'.$DBC_user['language'].'/common.php';
else
	error('There is no valid language pack \''.DBC_htmlspecialchars($DBC_user['language']).'\' installed. Please reinstall a language of that name');

// Check if we are to display a maintenance message
if ($DBC_config['o_maintenance'] && $DBC_user['g_id'] != DBC_ADMIN && $DBC_user['g_id'] != DBC_MOD && !defined('DBC_TURN_OFF_MAINT'))
	maintenance_message();

require DBC_ROOT.'engine/colorize_groups.php';

// Load cached bans
if (file_exists(FORUM_CACHE_DIR.'cache_bans.php'))
	include FORUM_CACHE_DIR.'cache_bans.php';

if (!defined('DBC_BANS_LOADED'))
{
	if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
		require DBC_ROOT.'engine/cache.php';

	generate_bans_cache();
	require FORUM_CACHE_DIR.'cache_bans.php';
}

// Check if current user is banned
check_bans();

// Update online list
$online_search = '';
$online_users = $online_guests = array();
update_users_online();

// Update online list
$onl_u = $onl_g = $onl_s = array();
if (!defined('WITT_ENABLE')) 
	update_users_online();

// Check to see if we logged in without a cookie being set
if ($DBC_user['is_guest'] && isset($_GET['login']))
	message($lang_common['No cookie']);

// The maximum size of a post, in bytes, since the field is now MEDIUMTEXT this allows ~16MB but lets cap at 1MB...
if (!defined('DBC_MAX_POSTSIZE'))
	define('DBC_MAX_POSTSIZE', 65535);

if (!defined('DBC_SEARCH_MIN_WORD'))
	define('DBC_SEARCH_MIN_WORD', 3);
if (!defined('DBC_SEARCH_MAX_WORD'))
	define('DBC_SEARCH_MAX_WORD', 20);
